package com.itheima.反射reflect.基于反射方式操作成员方法;

import java.lang.reflect.Method;

public class reflectDemo3 {
    public static void main(String[] args) throws Exception {
        //获取class对象
        Class clazz = Class.forName("com.itheima.反射reflect.基于反射方式操作成员方法.Teacher");
        //获取里面的method对象
        Method method3 = clazz.getDeclaredMethod("function6", String.class);
        //忽略安全检查
        method3.setAccessible(true);
        //创建Teacher对象
        Teacher teacher = (Teacher) clazz.newInstance();
        Object result = method3.invoke(teacher, "张老师");
        System.out.println(result);

    }
}
class Teacher{
    private String function6(String name){
        System.out.println("第六个，参数不变有返回"+name);
        return "老师来了";
    }
}